#ifndef GRID_H
#define GRID_H

#ifdef DX9

#include "NeroEngine\NEntity.h"
#include "NeroEngine\NFactory.h"
#include "NeroEngine\NEventSubscriber.h"

#if WIN_32
#include "Win32_DX9\Win32RenderEntity.h"
#include "Win32_DX9\Win32CustumVertex.h"
#include "Win32_DX9\Win32VertexBuffer.h"
#endif

#include <d3dx9.h>

const int MAX_GRID_SIZE = 100;
const int DEFAULT_SIZE = 100;
const int DEFAULT_DIVISIONS = 10;

class Grid :public Graphics::Win32RenderEntity, public Game::NEventSubscriber
{
	RTTI_DECLARATIONS(Grid, Graphics::Win32RenderEntity)

public:
	Grid();

	Grid(int size, int division);

	virtual ~Grid(void);

	void Render(float gameTime);

	void Initialize();

	virtual void Deinitialize(){}

	void Update(float gameTime);

	virtual int Serialize(Core::NArchive ar);

	virtual int Deserialize(Core::NArchive ar);

	virtual void Notify(Engine::NEventPublisher* aEventPublisher, float wallTime);

private:
	void Populate();
	
	int mSize;
	int mDivisions;
	
	int mDistBetweenSections;
	int mNumPrimatives;
	int mNumVerts;
	
	Graphics::CUSTOMVERTEX* mVertices;
	Graphics::Win32VertexBuffer mVertexBuffer;
};

ConcreteFactory(Grid, Engine::NEntity, Grid)

#endif
#endif